using System.Collections.Generic;
using UnityEngine;

public class CareerGroupLayer : UILayer
{
	public UITable table;

	public GameObject careerButtonPrefab;

	protected List<CareerListButton> buttons = new List<CareerListButton>();

	protected CareerSettings.CareerGroup group;

	public void ShowWithGroup(CareerSettings.CareerGroup group)
	{
		this.group = group;
		NavigationManager.instance.Push(base.gameObject);
	}

	public void Init()
	{
		int num = 0;
		foreach (CareerSettings.CareerOpponent opponent in group.opponents)
		{
			if (num >= buttons.Count)
			{
				GameObject gameObject = NGUITools.AddChild(table.gameObject, careerButtonPrefab);
				gameObject.name = GGFormat.IndexName(num);
				buttons.Add(gameObject.GetComponent<CareerListButton>());
			}
			CareerListButton careerListButton = buttons[num];
			careerListButton.Init(opponent);
			num++;
		}
		for (int i = num; i < buttons.Count; i++)
		{
			CareerListButton careerListButton2 = buttons[i];
			careerListButton2.gameObject.SetActive(false);
		}
		table.Reposition();
	}

	public void OnEnable()
	{
		Init();
	}
}
